<template>
	<view class="pd">
		<view class="tr ls pt20 pm20" @tap="hf('advanceList')">
			预支记录
		</view>
		<view class="bgff pd box yj8">
			<view class="  pt20 pm20 display-flex">
				<view class="flex-1">
					入职企业
				</view>
				<view class="z9 fz28 vertical-center">
					{{ret.companyName||'--'}}
				</view>
			</view>
			<view class="  pt20 pm20 display-flex btm">
				<view class="flex-1">
					员工工号
				</view>
				<view class="z9 fz28 vertical-center">
					{{ret.companyNo}}
				</view>
			</view>
			<view class="  pt20 pm20 display-flex btm">
				<view class="flex-1">
					姓名
				</view>
				<view class="z9 fz28 vertical-center">
					{{ret.realName}}
				</view>
			</view>
			<view class="  pt20 pm20 display-flex btm">
				<view class="flex-1">
					身份证
				</view>
				<view class="z9 fz28 vertical-center">
					{{ret.idCard}}
				</view>
			</view>
			<view class="  pt20 pm20 display-flex btm">
				<view class="flex-1 vertical-center tl">
					借款金额
				</view>
				<view class="z9 fz28 vertical-center">
					<view class="display-flex">
						<view class="" @tap="jnxcxzf(1)">
							<text class="iconfont icon-jian ls fz50 cz" :class="jxc==1?'xczxrer':''"></text>
						</view>
						<view class="kxczcftrt z3 vertical-center">
							<input type="number" @blur="kkxczxret" v-model="jxc" class="w100 h100 cz cen" />
						</view>
						<view class="" @tap="jnxcxzf(2)">
							<text class="iconfont icon-jia ls fz50 cz" :class="jxc>=10000?'xczxrer':''"></text>
						</view>
					</view>
				</view>
			</view>
			<view class="  pt20 pm20 display-flex btm">
				<view class="flex-1">
					打款方式
				</view>
				<view class="z9 fz28 vertical-center">
					<radio-group @change="radioChange" class="">
						<label class="xzczxctrt mr20" v-for="(item, index) in items" :key="item.value">
							<view class="display-flex">
								<view>
									<radio :value="item.value" class="kcxzvxcdrytr" :checked="index === 0" />
								</view>
								<view class="fz28 fgfdgdfgbty">{{item.name}}</view>
							</view>
						</label>

					</radio-group>
				</view>
			</view>
			<view class="" v-if="jnxsd==0">
				<view class="  pt20 pm20 display-flex btm">
					<view class="flex-1">
						卡名
					</view>
					<view class="z9 fz28 vertical-center">
						{{ret.payCardName}}
					</view>
				</view>
				<view class="  pt20 pm20 display-flex btm">
					<view class="flex-1">
						所属支行
					</view>
					<view class="z9 fz28 vertical-center">
						{{ret.payCardBranch}}
					</view>
				</view>
				<view class="  pt20 pm20 display-flex btm">
					<view class="flex-1">
						银行卡号
					</view>
					<view class="z9 fz28 vertical-center">
						{{ret.payCard}}
					</view>
				</view>
				<view class="red fz24 btm pt20 pm20">
					注:预支的薪资默认打款到本人实名认证提交的发薪卡
				</view>
			</view>
		</view>
			<view class="mt100">
				
				 <button type="default" disabled v-if="!ret.payCard" @tap="hf('payCardList')">请绑定发薪卡</button>
				  <button type="default" disabled v-else-if="!ret.isJob">您还未入职企业</button>
				  <button type="primary" @tap="qujxcsdft" v-else="ret.payCard">提交</button>
		</view>
	</view>
</template>
<script lang="ts" setup>
	import { ref } from "vue"
	import {hf,callBack,dxrequest, hfer} from "@/util/index.js"
	const jxc = ref(100)
	const jnxsd = ref(0)
	const ret = ref({})
	const items = [{
		value: '0',
		name: '发薪卡'
	},
	// {
	// 	value: '1',
	// 	name: '微信',
	// 	checked: 'true'
	// },
	]
	const jnxcxzf = (ty) => {
		if (ty == 1) {
			jxc.value -= 50
		} else {
			jxc.value += 50
		}
		if (jxc.value <= 0) {
			jxc.value = 1
		}
		if (jxc.value >= 10000) {
			jxc.value = 10000
		}
	}
	const kkxczxret = () => {
		if (jxc.value >= 10000) {
			jxc.value = 10000
		}
	}
	const radioChange = (data) => {
		jnxsd.value = data.detail.value
		
	}
	
	const getuser = async () => {
		const openid = uni.getStorageSync("openid")
		const { data } = await dxrequest("/api/user/" + openid)
		ret.value = data
	
	}
	getuser()
	
	const qujxcsdft = async()=>{
		ret.value.id = ""
		uni.showLoading({
			title:"加载中..."
		})
		const jzxdfs  =await dxrequest("/api/userbalancelog",{
			...ret.value,
			recordType:3,
			balance:jxc.value,
			recordChannel:1,
			isPass:1
		},"post")
		uni.hideLoading()
		hfer("advanceList")
	}
</script>

<style scoped>
	.kxczcftrt {
		width: 140rpx;
		height: 100%;
		background: #f2f2f2;
		margin-left: 10rpx;
		margin-right: 10rpx;
	}

	.xczxrer {
		opacity: 0.4;
	}
</style>